package com.job.sun.HomeWork0717;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 张春阳
 * @version 1.0
 * @since 2022-07-18 13:49:01
 */
public class USeFormat {
    public static void main(String[] args) throws ParseException {
        //时间模式
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        Date date = new Date();
  //日期格式化为字符
        String format = sdf.format(date);

        System.out.println(format);

        String str = "2008-08-08 12:00:01";
//异常  字符串解析为日期
        Date date1 = sdf. parse(str);

        System.out.println(date1);

        DecimalFormat decimalFormat = new DecimalFormat("RMB#,###,##0.00");
        String s = decimalFormat.format(1234570.97);
        System.out.println(s);
    }
}